/*
 * Filename:    HcpmsColumnUtil.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014-12-8
 */
package com.paic.mhis.hcpms.itextpdf.web.util;

import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfContentByte;

public class HcpmsColumnUtil {

	public static ColumnText createColumnTile(PdfContentByte cb, Phrase phrase, int llx, int lly, int urx, int ury,
			int m, int align) {
		ColumnText ctx = new ColumnText(cb);
		try {
			ctx.setSimpleColumn(phrase, llx, lly, urx, ury, m, align);
			ctx.go();
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return ctx;
	}

	public static void createColumnText2Cell(PdfContentByte cb, Phrase phraseLeft, Phrase phraseRight, int llx,
			int lly, int urx, int ury, int align) {
		ColumnText ctx = new ColumnText(cb);
		try {
			int leftEendx = urx / 2;
			ctx.setSimpleColumn(llx, lly, leftEendx, ury);
			ctx.addText(phraseLeft);
			ctx.setAlignment(align);
			ctx.setLeading(8);
			ctx.go();
			ctx = new ColumnText(cb);
			ctx.setSimpleColumn(leftEendx, lly, urx, ury);
			ctx.addText(phraseRight);
			ctx.setAlignment(align);
			ctx.go();
		} catch (DocumentException e) {
			e.printStackTrace();
		}

	}

	public static void createColumnTextTitll(PdfContentByte cb, Phrase phraseTitll, Phrase phraseContent, int llx,
			int lly, int urx, int ury, int align) {
		ColumnText ctx = new ColumnText(cb);
		try {
			ctx.setSimpleColumn(llx, lly, urx, ury);
			ctx.addText(phraseTitll);
			ctx.addText(phraseContent);
			ctx.setAlignment(align);
			ctx.setLeading(8);
			ctx.go();
		} catch (DocumentException e) {
			e.printStackTrace();
		}

	}

	public static void createColumnTextTitll(PdfContentByte cb, Phrase phraseTitll, Phrase content1, Phrase content2,
			Phrase content3, int llx, int lly, int urx, int ury, int align) {
		ColumnText ctx = new ColumnText(cb);
		try {
			ctx.setSimpleColumn(llx, lly, urx, ury);
			ctx.addText(phraseTitll);
			ctx.addText(content1);
			ctx.addText(content2);
			ctx.addText(content3);
			ctx.setAlignment(align);
			ctx.setLeading(8);
			ctx.go();
		} catch (DocumentException e) {
			e.printStackTrace();
		}

	}

	public static void createColumnTextCell(PdfContentByte cb, Phrase phraseLeft, int llx, int lly, int urx, int ury,
			int align) {
		ColumnText ctx = new ColumnText(cb);
		try {
			ctx.setSimpleColumn(llx, lly, urx, ury);
			ctx.addText(phraseLeft);
			ctx.setAlignment(align);
			ctx.setLeading(8);
			ctx.go();
		} catch (DocumentException e) {
			e.printStackTrace();
		}

	}
}
